<template>
	<om-page>
		<scroll-view scroll-y class="" style="">
			<view class="" style="display: flex;flex-wrap: wrap;">
				<view v-for="(item,index) of objList" :key="index" style="margin-left: 40rpx;margin-top: 15rpx; display: flex; flex-direction:column;align-items: center;">
					<view class="om-btn-color" style="position: relative;color: #ffffff;font-size: 28rpx; width:80rpx;height:80rpx;display: flex; align-items: center;justify-content: center;">
						{{item.sortName}}
						<image src="/static/images/others/delete1.png" @click="userItemClick(index)":type="'clear'" :color="'#666666'" size="18" style="width:40rpx;height:40rpx;border-radius:20rpx; position: absolute;top:-10rpx;right: -15rpx;" />
					</view>
					<text  style="font-size: 25rpx;">
						{{item.name}}	
					</text>
				</view>
			</view>
			
		</scroll-view >
	</om-page>
</template>

<script>
	export default{
		data(){
			return{
				objList:[],
				nameStr:'',
				idStr:''
			}
		},
		methods:{
			userItemClick(index){
				let pages = getCurrentPages();
				let prePage = pages[pages.length - 2]
				//#ifdef APP-PLUS
				for (var iref in prePage.$vm.$refs) {
					var formdata = prePage.$vm.$refs[iref].formdata
					var autoform =  prePage.$vm.$refs[iref]
					autoform.userItemClick(this.nameStr,this.idStr,index)
					this.objList.splice(index,1)
					this.$forceUpdate()
				}
				//#endif
				//#ifndef APP-PLUS
				for (var iref in prePage.$refs) {
					var formdata = prePage.$refs[iref].formdata
					var autoform =  prePage.$refs[iref]
					autoform.userItemClick(this.nameStr,this.idStr,index)
					this.objList.splice(index,1)
					this.$forceUpdate()
				}
				//#endif
			}
		},
		onLoad(options){
			let pages = getCurrentPages();
			this.nameStr = options.name
			this.idStr = options.id
			if (pages.length > 2) {
				let prePage = pages[pages.length - 2]
				//#ifdef APP-PLUS
				for (var iref in prePage.$vm.$refs) {
					var autoform = prePage.$vm.$refs[iref]
					let idList = autoform.formdata[this.idStr].split(',')
					let nameList = autoform.formdata[this.nameStr].split(',')
					if(autoform.formdata[this.idStr]){
						for(let index in idList){
							let obj =  {
								id:idList[index],
								name:nameList[index],
								sortName:nameList[index].substr(nameList[index].length-2,nameList[index].length),
							}
							this.objList.push(obj)
						}
					}
					break
				}
				//#endif
				//#ifndef APP-PLUS
				for (var iref in prePage.$refs) {
					var autoform = prePage.$refs[iref]
					let idList = autoform.formdata[this.idStr].split(',')
					let nameList = autoform.formdata[this.nameStr].split(',')
					if(autoform.formdata[this.idStr]){
						for(let index in idList){
							let obj =  {
								id:idList[index],
								name:nameList[index],
								sortName:nameList[index].substr(nameList[index].length-2,nameList[index].length),
							}
							this.objList.push(obj)
						}
					}
					break
				}
				//#endif
				
			}
		}
	}
</script>

<style scoped>
</style>                                                  
